package com.metagurukul.informer.service;

import java.sql.SQLException;
import java.util.List;
import com.metagurukul.informer.dao.SearchDAO;
import com.metagurukul.informer.dao.TagDAO;
import com.metagurukul.informer.valueObjects.Questions;
import com.metagurukul.informer.valueObjects.Tags;

public class TagSearchService {
	private int tagId ; 
	public TagSearchService() {}
	
	public TagSearchService(int tagId) {
		this.tagId = tagId;
	}
	/**
	 * 
	 * @return list of question for requested tag
	 * @throws SQLException
	 */
	public List<Questions> questionList() throws SQLException {
		SearchDAO searchdao = new SearchDAO();
		return searchdao.findQuestionsByTag(tagId);
	}
	/**
	 * return list of tags by question_id
	 * @param question_id
	 * @return
	 * @throws SQLException
	 */
    public List<Tags> searchTags(int question_id) throws SQLException{
    	return new TagDAO().showTagsByQuestionId(question_id);
    }
    /**
     * 
     * @param tagId
     * @return tag name for requested tagid
     * @throws SQLException
     */
	public String findTagName(int tagId) throws SQLException {
		return new TagDAO().findByTagId(tagId);
	}
	/**
	 * 
	 * @param tagName
	 * @return 
	 * @throws SQLException
	 */
	public String findByTagName(String tagName) throws SQLException{
    	return new TagDAO().findByTagName(tagName);
    }
    
}
